package com.cy.pj.goods.dao;


import com.cy.pj.goods.pojo.Goods;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Copyright (C), 2015-2020, XXX有限公司
 * FileName: GoodsDaoImpl
 * Author:   ASUS
 * Date:     2020/9/29 14:25
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
/**
 * 自定义GoodsDao接口的实现类,在此实现类中基于SqlSession对象
 * 实现与数据库的会话.
 */
@Repository
public class GoodsDaoImpl implements GoodsDao{

    @Autowired
    private SqlSessionFactory sqlSessionFactory;

    @Override
    public List<Goods> findGoods() {
        //1,获取SqlSession对象
        SqlSession session = sqlSessionFactory.openSession();
        //2,基于SqlSession实现视频查询
        String statement = "com.cy.pj.goods.dao.GoodsDao.findGoods";//namespace+elementId
        List<Goods> list = session.selectList(statement);
        //3,释放资源
        session.close();
        //4,返回结果
        return list;
    }
}
